#include "Log.h"

#include <string.h>
#include <fan-llvm/core/Core.h>
#include "Type.h"
#include "UnsupportedErr.h"


Type* Log_classType = NULL;
VTable* Log_classVTable = NULL;


/**********************************************
 *
 * Methods and fields
 *
 **********************************************/


/* Void make(Str name, Bool register) */
void Log_make(Log* self, Str* name, Bool reg)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.make not implemented yet"));
}


/* Str toStr() */
Str* Log_toStr(Obj self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.toStr not implemented yet"));
}


/* LogLevel level */
LogLevel* Log_level(Log* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.level not implemented yet"));
}


/* LogLevel level */
void Log_setLevel(Log* self, LogLevel* val)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.level not implemented yet"));
}


/* Log[] list() */
List* Log_list(void)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.list not implemented yet"));
}


/* Log? find(Str name, Bool checked) */
Log* Log_find_1(Str* name)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.find not implemented yet"));
}


/* Log? find(Str name, Bool checked) */
Log* Log_find(Str* name, Bool checked)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.find not implemented yet"));
}


/* Log get(Str name) */
Log* Log_get(Str* name)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.get not implemented yet"));
}


/* Str name() */
Str* Log_name(Log* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.name not implemented yet"));
}


/* Bool isEnabled(LogLevel level) */
Bool Log_isEnabled(Log* self, LogLevel* level)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.isEnabled not implemented yet"));
}


/* Bool isErr() */
Bool Log_isErr(Log* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.isErr not implemented yet"));
}


/* Bool isWarn() */
Bool Log_isWarn(Log* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.isWarn not implemented yet"));
}


/* Bool isInfo() */
Bool Log_isInfo(Log* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.isInfo not implemented yet"));
}


/* Bool isDebug() */
Bool Log_isDebug(Log* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.isDebug not implemented yet"));
}


/* Void err(Str msg, Err? err) */
void Log_err_1(Log* self, Str* msg)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.err not implemented yet"));
}


/* Void err(Str msg, Err? err) */
void Log_err(Log* self, Str* msg, Err* err)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.err not implemented yet"));
}


/* Void warn(Str msg, Err? err) */
void Log_warn_1(Log* self, Str* msg)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.warn not implemented yet"));
}


/* Void warn(Str msg, Err? err) */
void Log_warn(Log* self, Str* msg, Err* err)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.warn not implemented yet"));
}


/* Void info(Str msg, Err? err) */
void Log_info_1(Log* self, Str* msg)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.info not implemented yet"));
}


/* Void info(Str msg, Err? err) */
void Log_info(Log* self, Str* msg, Err* err)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.info not implemented yet"));
}


/* Void debug(Str msg, Err? err) */
void Log_debug_1(Log* self, Str* msg)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.debug not implemented yet"));
}


/* Void debug(Str msg, Err? err) */
void Log_debug(Log* self, Str* msg, Err* err)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.debug not implemented yet"));
}


/* Void log(LogRec rec) */
void Log_log(Log* self, LogRec* rec)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.log not implemented yet"));
}


/* |LogRec->Void|[] handlers() */
List* Log_handlers(void)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.handlers not implemented yet"));
}


/* Void addHandler(|LogRec->Void| handler) */
void Log_addHandler(Func* handler)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.addHandler not implemented yet"));
}


/* Void removeHandler(|LogRec->Void| handler) */
void Log_removeHandler(Func* handler)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Log.removeHandler not implemented yet"));
}


/**********************************************
 *
 * Type-system functions
 *
 **********************************************/


Type* Log_initType(void)
{
  if (Log_classType == NULL)
  {
    Type* baseType = Obj_initType();
    VTable* vtable = Log_initVTable();
    Type* type = Type_new("Log", baseType, vtable, sizeof(Log), sizeof(LogVTable));
    Type_registerCtorImplementation(type, "make", Log_make, 2);
    Type_registerMethodImplementation(type, "addHandler", Log_addHandler, 1);
    Type_registerMethodImplementation(type, "debug", Log_debug_1, 1);
    Type_registerMethodImplementation(type, "debug", Log_debug, 2);
    Type_registerMethodImplementation(type, "err", Log_err_1, 1);
    Type_registerMethodImplementation(type, "err", Log_err, 2);
    Type_registerMethodImplementation(type, "find", Log_find_1, 1);
    Type_registerMethodImplementation(type, "find", Log_find, 2);
    Type_registerMethodImplementation(type, "get", Log_get, 1);
    Type_registerMethodImplementation(type, "handlers", Log_handlers, 0);
    Type_registerMethodImplementation(type, "info", Log_info_1, 1);
    Type_registerMethodImplementation(type, "info", Log_info, 2);
    Type_registerMethodImplementation(type, "isDebug", Log_isDebug, 0);
    Type_registerMethodImplementation(type, "isEnabled", Log_isEnabled, 1);
    Type_registerMethodImplementation(type, "isErr", Log_isErr, 0);
    Type_registerMethodImplementation(type, "isInfo", Log_isInfo, 0);
    Type_registerMethodImplementation(type, "isWarn", Log_isWarn, 0);
    Type_registerMethodImplementation(type, "list", Log_list, 0);
    Type_registerMethodImplementation(type, "log", Log_log, 1);
    Type_registerMethodImplementation(type, "name", Log_name, 0);
    Type_registerMethodImplementation(type, "removeHandler", Log_removeHandler, 1);
    Type_registerMethodImplementation(type, "toStr", Log_toStr, 0);
    Type_registerMethodImplementation(type, "warn", Log_warn_1, 1);
    Type_registerMethodImplementation(type, "warn", Log_warn, 2);
    Type_registerFieldImplementation(type, "level", Log_level, Log_setLevel);
    Log_classType = type;
    Log_initStatic();
  }
  return Log_classType;
}


VTable* Log_initVTable(void)
{
  if (Log_classVTable == NULL)
  {
    VTable* vtable = memoryAlloc(sizeof(LogVTable));
    memcpy(vtable, Obj_initVTable(), sizeof(FanObjVTable));
    ((FanObjVTable*)vtable)->toStr = Log_toStr;
    ((LogVTable*)vtable)->log = Log_log;
    Log_classVTable = vtable;
  }
  return Log_classVTable;
}


void Log_initStatic(void)
{
}
